﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinForm
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void textBox1_TextChanged(object sender, EventArgs e)
        {


        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void cal_click(object sender, EventArgs e)
        {
            string strA = num1.Text.Trim();
            string strB = num2.Text.Trim();
            int a = Convert.ToInt32(strA);
            int b = Convert.ToInt32(strB);
            string str = strOp.SelectedItem.ToString();
            // 给c一个初始值
            int c = 0;
            if (str.Contains("+"))
            {
                c = a + b;
            }
            else if (str.Contains("-"))
            {
                c = a - b;
            }
            else if (str.Contains("/"))
            {
                c = a / b;
            }
            else if (str.Contains("*"))
            {
                c = a * b;
            }
            else
            {
                // 可以在这里处理不包含预期运算符的情况，比如给出提示
                res.Text = "运算符错误";
                // 提前返回，避免执行下面的res.Text = c.ToString();
                return;
            }
            res.Text = c.ToString();
        }

        private void exit_click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
    }
}
